'''
@since: 22.03.2014

@author: Max

@summary: Diese Klasse ist verantwortlich fuer das Auffauen eines Huds
'''

import pygame    # @UnusedImport

from Properties import *    # @UnusedWildImport
from Tile import *
from Tileset import *    # @UnusedWildImport
from Messages import TILE_NOTHING_SELECTED
from ai.Worker import *
# from pygame.locals import *


class Hud():
    def __init__(self):
        self.surface = pygame.Surface([GAMELOGIC_SCREEN_WIDTH, GAMELOGIC_SCREEN_HEIGHT]).convert()
        """@ivar: Leinwand auf die alle HUD-Elemente gezeichnet werden."""
        self.surface.set_colorkey(COLOR_BLACK)
       
        self.Tileset = Tileset(RESOURCES_MAP_TILESET)
        
        self.buildBar = []
        
        self.buildBar.append(Tile((16, GAMELOGIC_SCREEN_HEIGHT - 32), self.Tileset.getTile(1), 1))
        self.buildBar.append(Tile((40, GAMELOGIC_SCREEN_HEIGHT - 32), self.Tileset.getTile(6), 6))
        
        self.selectedInfoFont = pygame.font.Font(None, 30)
        self.selectedInfoText = TILE_NOTHING_SELECTED
    
    def isInHud(self, pos):
        """
        Ueberprueft, ob ein Mausklick im HUD war
        @param pos: Position des Mausklicks
        """
        for element in self.buildBar:
            if pos[0] >= element.pos[0] and pos[0] <= element.pos[0] + TILESET_TILE_HEIGHT:
                if pos[1] >= element.pos[1] and pos[1] <= element.pos[1] + TILESET_TILE_WIDTH:
                    return True, element
        return False, None    
        
    def update(self):
        self.selectedInfoRender = self.selectedInfoFont.render(self.selectedInfoText, 0, COLOR_WHITE)   
        
    def render(self, gLogic):
        self.surface.fill(COLOR_BLACK)
        self.surface.blit(self.buildBar[0].image, self.buildBar[0].pos)
        self.surface.blit(self.buildBar[1].image, self.buildBar[1].pos)     
        self.surface.blit(self.selectedInfoRender, (16, GAMELOGIC_SCREEN_HEIGHT - 70))
        gLogic.screen.blit(self.surface, (0, 0))
        
        
        
        
        
        
        
        
     
        
        
        
        
        
        
        
        
                            
                              
    
